Código fuente de 'Ordena array.asp'

<html>

<head>
<title>Ordena array - Códigos asp, programacion asp, descargas asp, rutinas asp</title>
</head>

<p align="center"><b><font size="3">Ordena array</font></b>
<body style="font-family: Arial; font-size: 11pt"></p>

<!-- Vbscript function that sorts an one-dimensional array of number either ascending or descending. This function sorts using the well known double for..next principle. Script gives an overview of passing parameters and especially passing arrays of numbers to a function.

  '**************************************
    ' Name: Sort arrays
    
    ' Description:Vbscript function that sorts an one-dimensional array of number either ascending
    ' or descending.
    ' This function sorts using the well known Double for..next principle. 
    ' Script gives an overview of passing parameters and especially passing arrays of numbers To a function.
    ' By: Rogier Doekes
    '
    ' Inputs:The function gets as input an unsorted array, plus 1 For ascending sorting or something Else 
    ' For descending sorting
    '
    ' Returns:The function returns
    a sorted array of numbers.
    '
    ' Assumes:Using SQL sorting is not a problem. However, For those cases when there is no SQL To sort with, 
    or an array of numbers is manipulated requiring a sort, this function might come In handy. 
    Also, VBscript does Not have a build-in sorting function.
    '
      http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=6495&lngWId=4    'for details.    '**************************************
-->
    
<%    '--------Begin Function----
    function fnSort(OrdenaVector, intAsc)
    Dim intTempStore
    Dim i, j 
    For i = 0 To UBound(OrdenaVector) - 1
    For j = i To UBound(OrdenaVector)
    'Sort Ascending
    if intAsc = 1 Then
    if OrdenaVector(i) > OrdenaVector(j) Then
    intTempStore = OrdenaVector(i)
    OrdenaVector(i) = OrdenaVector(j)
    OrdenaVector(j) = intTempStore
    End if 'i > j
    'Sort Descending
    Else
    if OrdenaVector(i) < OrdenaVector(j) Then
    intTempStore = OrdenaVector(i)
    OrdenaVector(i) = OrdenaVector(j)
    OrdenaVector(j) = intTempStore
    End if 'i < j
    End if 'intAsc = 1
    Next 'j
    Next 'i
    fnSort = OrdenaVector
    'response.write fnsort(0)
    End function 'fnSort
    '-------------------------
    Dim aUnSort(3), Ordenar
    aUnSort(0) = 4
    aUnSort(1) = 2
    aUnSort(2) = 6
    aUnSort(3) = 20
    'call the function
    'second argument:
    ' * ascending sorted = 1
    ' * descending sorting = any other character
    Ordenar = fnSort(aUnSort, 1)
    response.write "<b>Valores del array original: </b> 4,2,6,20<br>"
    Response.write "<b>Valores ordenados: </b>"
    For j = 0 To UBound(Ordenar)
    if j>0 then response.write ","
    response.write Ordenar(j)
    next
    
    Erase aUnSort
%>

</body>
</html>